Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Fernflower decompiler into Quarkus build of fast-jar #15162

Merged
merged 1 commit into from
Feb 19, 2021

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Feb 18, 2021

This makes it easy for Quarkus developers and extension authors
to see the bytecode that Quarkus produces (both generated and transformed)

Fixes: #612

@geoand
Copy link
Contributor Author

geoand commented Feb 18, 2021

cc @FroMage @stuartwdouglas

@@ -667,6 +700,56 @@ public void accept(Path path) {
return new JarBuildItem(initJar, null, libDir, packageConfig.type, null);
}

private void downloadFernflowerJar(PackageConfig packageConfig, Path fernflowerJar) {
String downloadURL = String.format("https://jitpack.io/com/github/fesh0r/fernflower/%s/fernflower-%s.jar",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we download it rather than making it a build dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning is that this is super unlikely to be used by regular users, so there should be no reason to make it an explicit dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it's not on Maven Central but maybe we could ask nicely?

Copy link
Contributor Author

@geoand geoand Feb 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was going to mention that as well.

For the time being it's only available on Jitpack because some fellow forked the Jetbrains repo and configured Jitpack.

I'll open an issue on the Jetbrains tracker to see if we can get it into Maven Central

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit more complicated than that. We had quite a lot of corporate users complaining it's hard to download things outside of Maven Central. So downloading from Maven Central is usually the way to go. Not sure downloading it always would be a big issue given how many artifacts people get to download to do a build. But I have no idea how big it is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also with Maven, you get signature checking, automatic updates with Dependabot and so on.

It's not on Maven atm so we can't really do anything about it but maybe we could ask?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I have no idea how big it is.

For the hash I have used, the jar is around 600kB

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to suggest making this default to true if the current user is stephane, but that jar thing looks like an attack vector :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahahhah

@geoand geoand force-pushed the #612 branch 4 times, most recently from 67dbb66 to ea66351 Compare February 18, 2021 11:10
This makes it easy for Quarkus developers and extension authors
to see the bytecode that Quarkus produces

Fixes: quarkusio#612
@geoand
Copy link
Contributor Author

geoand commented Feb 18, 2021

The gradle failure is the same seen in other PRs, it has nothing to do with this PR

Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome. Didn't I write some exception catcher that dumped a disassembled class using ASM, somewhere?

Is this decompiler better than the ASM one?

Does it deal with the non-iodiomatic-Java bytecode we can produce?

@geoand
Copy link
Contributor Author

geoand commented Feb 18, 2021

That's awesome. Didn't I write some exception catcher that dumped a disassembled class using ASM, somewhere?

Good question! I don't really know where that is...

Is this decompiler better than the ASM one?

Does it deal with the non-iodiomatic-Java bytecode we can produce?

It's the decompiler IntelliJ uses and in all my experience with it and Quarkus, I have never opened a class file produced by Quarkus in it and not see a meaningful result.

@geoand
Copy link
Contributor Author

geoand commented Feb 19, 2021

Can I get a review of this please?

Thanks :)

@FroMage
Copy link
Member

FroMage commented Feb 19, 2021

IllegalClassExceptionMapper in quarkus-resteasy-reactive-deployment. It dumps the offending method's bytecode, but it doesn't disassemble it because well, the bytecode is invalid…

So OK, not really the same thing as your PR. But we should really do something with it more generally because that's damn useful for devs.

@geoand
Copy link
Contributor Author

geoand commented Feb 19, 2021

generally because tha

Ah, right! We should definitely expand on it!

@geoand geoand merged commit c8919cf into quarkusio:master Feb 19, 2021
@quarkus-bot quarkus-bot bot added this to the 1.13 - master milestone Feb 19, 2021
@geoand geoand deleted the #612 branch February 19, 2021 09:26
@FroMage
Copy link
Member

FroMage commented Feb 19, 2021

So, if I am developing an extension and I fuck up my bytecode, with invalid ASM or even gizmo (invokevirtual instead of invokeinterface happened to me yesterday, though I don't expect that particular issue to crash a decompiler). What is the behaviour of this plugin? Does it crash or fall back to printing bytecodes or what?

@geoand
Copy link
Contributor Author

geoand commented Feb 19, 2021

It never crashes. In the worst case a .java file will be generated with a comment from the decompiler that it couldn't figure out the proper java code.

It is also smart enough to limit this to a specific method if the bytecode is part of a method - the rest of the class should be decompiled properly (or at least that is what I have seen in practice)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print disassembly of generated bytecode
3 participants